package com.xyzh05.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

@Entity
@Table(name="service")
@Searchable
@XmlRootElement
public class Service extends BaseObject implements Serializable {
	private static final long serialVersionUID = 7518407662989148435L;
	
	private Long id;
    private String servicename;
    private String description;
    private Double minprice;
    private Double maxprice;
    private Double price;
    private Long difficulty;
    private Long period;
    private String process;
    private Double pay;
    private Long binary;
    private Integer point;
    private String infoCollectFilePath;
    private Integer modifyPeriod;
//    private Long category;
    private Double stepPrice;
	private ServiceType serviceType;

    @Id @GeneratedValue(strategy=GenerationType.AUTO) @SearchableId    
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    @Column(name="servicename", nullable=false)
    @SearchableProperty
    public String getServicename() {
        return this.servicename;
    }
    
    public void setServicename(String servicename) {
        this.servicename = servicename;
    }
    
    @Column(name="description", length=65535)
    @SearchableProperty
    public String getDescription() {
        return this.description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    @Column(name="minprice", nullable=false, precision=22, scale=0)
    @SearchableProperty
    public Double getMinprice() {
        return this.minprice;
    }
    
    public void setMinprice(Double minprice) {
        this.minprice = minprice;
    }
    
    @Column(name="maxprice", nullable=false, precision=22, scale=0)
    @SearchableProperty
    public Double getMaxprice() {
        return this.maxprice;
    }
    
    public void setMaxprice(Double maxprice) {
        this.maxprice = maxprice;
    }
    
    @Column(name="price", nullable=false, precision=22, scale=0)
    @SearchableProperty
    public Double getPrice() {
        return this.price;
    }
    
    public void setPrice(Double price) {
        this.price = price;
    }
    
    @Column(name="difficulty", nullable=false)
    @SearchableProperty
    public Long getDifficulty() {
        return this.difficulty;
    }
    
    public void setDifficulty(Long difficulty) {
        this.difficulty = difficulty;
    }
    
//    @Column(name="servicetype", nullable=false)
//    @SearchableProperty
//    public Long getServicetype() {
//        return this.servicetype;
//    }
//    
//    public void setServicetype(Long servicetype) {
//        this.servicetype = servicetype;
//    }
    
    @Column(name="period", nullable=false)
    @SearchableProperty
    public Long getPeriod() {
        return this.period;
    }
    
    public void setPeriod(Long period) {
        this.period = period;
    }
    
    @Column(name="process", length=65535)
    @SearchableProperty
    public String getProcess() {
        return this.process;
    }
    
    public void setProcess(String process) {
        this.process = process;
    }
    
    @Column(name="pay", nullable=false, precision=22, scale=0)
    @SearchableProperty
    public Double getPay() {
        return this.pay;
    }
    
    public void setPay(Double pay) {
        this.pay = pay;
    }
    
    @Column(name="binary")
    @SearchableProperty
    public Long getBinary() {
        return this.binary;
    }
    
    public void setBinary(Long binary) {
        this.binary = binary;
    }
    
    @Column(name="point", nullable=false)
    @SearchableProperty
    public Integer getPoint() {
        return this.point;
    }
    
    public void setPoint(Integer point) {
        this.point = point;
    }
    
    @Column(name="infoCollectFilePath")
    @SearchableProperty
    public String getInfoCollectFilePath() {
        return this.infoCollectFilePath;
    }
    
    public void setInfoCollectFilePath(String infoCollectFilePath) {
        this.infoCollectFilePath = infoCollectFilePath;
    }
    
    @Column(name="modifyperiod", nullable=false)
    @SearchableProperty
    public Integer getModifyPeriod() {
        return this.modifyPeriod;
    }
    
    public void setModifyPeriod(Integer modifyperiod) {
        this.modifyPeriod = modifyperiod;
    }
    
//    @Column(name="category")
//    @SearchableProperty
//    public Long getCategory() {
//        return this.category;
//    }
//    
//    public void setCategory(Long category) {
//        this.category = category;
//    }
    
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="category")
    public ServiceType getServiceType() {
		return serviceType;
	}

	public void setServiceType(ServiceType serviceType) {
		this.serviceType = serviceType;
	}

	public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Service pojo = (Service) o;

        if (servicename != null ? !servicename.equals(pojo.servicename) : pojo.servicename != null) return false;
        if (description != null ? !description.equals(pojo.description) : pojo.description != null) return false;
        if (minprice != null ? !minprice.equals(pojo.minprice) : pojo.minprice != null) return false;
        if (maxprice != null ? !maxprice.equals(pojo.maxprice) : pojo.maxprice != null) return false;
        if (price != null ? !price.equals(pojo.price) : pojo.price != null) return false;
        if (difficulty != null ? !difficulty.equals(pojo.difficulty) : pojo.difficulty != null) return false;
//        if (servicetype != null ? !servicetype.equals(pojo.servicetype) : pojo.servicetype != null) return false;
        if (period != null ? !period.equals(pojo.period) : pojo.period != null) return false;
        if (process != null ? !process.equals(pojo.process) : pojo.process != null) return false;
        if (pay != null ? !pay.equals(pojo.pay) : pojo.pay != null) return false;
        if (binary != null ? !binary.equals(pojo.binary) : pojo.binary != null) return false;
        if (point != null ? !point.equals(pojo.point) : pojo.point != null) return false;
        if (infoCollectFilePath != null ? !infoCollectFilePath.equals(pojo.infoCollectFilePath) : pojo.infoCollectFilePath != null) return false;
        if (modifyPeriod != null ? !modifyPeriod.equals(pojo.modifyPeriod) : pojo.modifyPeriod != null) return false;
//        if (category != null ? !category.equals(pojo.category) : pojo.category != null) return false;
        if (stepPrice != null ? !stepPrice.equals(pojo.stepPrice) : pojo.stepPrice != null) return false;

        return true;
    }
    
    @Column(name="stepprice", precision=22, scale=0)
    @SearchableProperty
    public Double getStepPrice() {
		return stepPrice;
	}

	public void setStepPrice(Double stepPrice) {
		this.stepPrice = stepPrice;
	}

	public int hashCode() {
        int result = 0;
        result = (servicename != null ? servicename.hashCode() : 0);
        result = 31 * result + (description != null ? description.hashCode() : 0);
        result = 31 * result + (minprice != null ? minprice.hashCode() : 0);
        result = 31 * result + (maxprice != null ? maxprice.hashCode() : 0);
        result = 31 * result + (price != null ? price.hashCode() : 0);
        result = 31 * result + (difficulty != null ? difficulty.hashCode() : 0);
//        result = 31 * result + (servicetype != null ? servicetype.hashCode() : 0);
        result = 31 * result + (period != null ? period.hashCode() : 0);
        result = 31 * result + (process != null ? process.hashCode() : 0);
        result = 31 * result + (pay != null ? pay.hashCode() : 0);
        result = 31 * result + (binary != null ? binary.hashCode() : 0);
        result = 31 * result + (point != null ? point.hashCode() : 0);
        result = 31 * result + (infoCollectFilePath != null ? infoCollectFilePath.hashCode() : 0);
        result = 31 * result + (modifyPeriod != null ? modifyPeriod.hashCode() : 0);
//        result = 31 * result + (category != null ? category.hashCode() : 0);
        result = 31 * result + (stepPrice != null ? stepPrice.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("id").append("='").append(getId()).append("', ");
        sb.append("servicename").append("='").append(getServicename()).append("', ");
        sb.append("description").append("='").append(getDescription()).append("', ");
        sb.append("minprice").append("='").append(getMinprice()).append("', ");
        sb.append("maxprice").append("='").append(getMaxprice()).append("', ");
        sb.append("price").append("='").append(getPrice()).append("', ");
        sb.append("difficulty").append("='").append(getDifficulty()).append("', ");
//        sb.append("servicetype").append("='").append(getServicetype()).append("', ");
        sb.append("period").append("='").append(getPeriod()).append("', ");
        sb.append("process").append("='").append(getProcess()).append("', ");
        sb.append("pay").append("='").append(getPay()).append("', ");
        sb.append("binary").append("='").append(getBinary()).append("', ");
        sb.append("point").append("='").append(getPoint()).append("', ");
        sb.append("infoCollectFilePath").append("='").append(getInfoCollectFilePath()).append("', ");
        sb.append("modifyperiod").append("='").append(getModifyPeriod()).append("', ");
//        sb.append("category").append("='").append(getCategory()).append("', ");
        sb.append("stepprice").append("='").append(getStepPrice()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
